#include "searchplacewid.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "PlaceManger.h"
#include <QMessageBox>
#include <QDebug>

SearchPlaceWid::SearchPlaceWid(QWidget *parent) : QWidget(parent)
{
    QHBoxLayout *hlayout = new QHBoxLayout(this);
//    QVBoxLayout *vlayout = new QVBoxLayout(this);
    this->nameEdit = new QLineEdit(this);
    this->nameLab = new QLabel("请输入您要查询的景点名称：",this);
    this->btn = new QPushButton("查找",this);
    nameEdit->setPlaceholderText("支持关键字查询");
    hlayout->addWidget(nameLab);
    hlayout->addWidget(nameEdit);
    hlayout->addWidget(btn);
//    vlayout->addLayout(hlayout);
//    vlayout->addWidget(btn);
    connect(btn,&QPushButton::released,this,[=](){
        char *name = (char *)this->nameEdit->text().toStdString().c_str();
//        if(strcmp(name,"")==0)
//        {
//            QMessageBox::information(this,"warning","你输入的内容为空!");
//            return ;
//        }

        emit seaRes(name);
    });
    connect(this->nameEdit,&QLineEdit::textChanged,[=](){
        emit seaRes((char *)this->nameEdit->text().toStdString().c_str());
    });
}
